{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ae0550aa",
   "metadata": {},
   "source": [
    "# week2的作业加笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8878e7c2",
   "metadata": {},
   "source": [
    "### 调用datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "80ac202a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8894d1d9",
   "metadata": {},
   "source": [
    "##### 前一个datetime是要从中导入可重用代码的标准库模块的名字；后一个datetime是子模块的名字。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "80b3aa60",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "562813b0",
   "metadata": {},
   "source": [
    "#### python中一行结束就标志着一条语句结束  \n",
    "#### 这个列表已经存在，而且已经赋给odds变量（通过使用赋值操作符=），它包含所示的这些数字。\n",
    "\n",
    "###### ①python中的列表也用中括号（[]）表示；②python中的列表可以包含任意类型的数据，甚至可以在一个列表中混合不同的数据类型 ②odds是一个整数列表，注意：这个odds列表跨三行，尽管这只是一条语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "427b22b1",
   "metadata": {},
   "outputs": [],
   "source": [
    "right_this_minute =datetime.today().minute"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "153e879e",
   "metadata": {},
   "source": [
    "#####  （）这里调用一个值，这个值将赋给一个变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f9b3bc5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a972c774",
   "metadata": {},
   "source": [
    "##### 这个“if”语句结果为“True\"或“False\".\n",
    "##### \"in\"操作符非常强大，它能确定一个对象是不是在另一个对象里。in操作符会返回True或False.\n",
    "##### \"print\"函数会在标准输出上（也就是你的屏幕）显示一个消息。\n",
    "##### 代码组可以包含嵌套代码组\n",
    "##### 冒号引入一个缩进的代码组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "13dcb480",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f01ff7c9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "59ff9cbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf0fc250",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a2202097",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a201b92",
   "metadata": {},
   "source": [
    "##### 并不是一定要把imports放在代码最上面，但是对python程序员来说，这是一个约定俗成的做法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "04780fab",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "39bc1224",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n",
      "Not an odd minute.\n",
      "Not an odd minute.\n",
      "Not an odd minute.\n",
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    right_this_minute =datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"Not an odd minute.\")\n",
    "    wait_time = random.randint(1,60)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be4cd6d9",
   "metadata": {},
   "source": [
    "##### for循环准确地迭代5次。for循环可以用来迭代固定次数，如果能提前知道需要循环多少次就可以使用for。for循环可以迭代处理任意的序列（如列表或字符串），也可以执行固定的次数（利用range函数）\n",
    "#####  random模块有一个非常有用的函数，名为randint，它会生成指定范围内的一个随机整数。\n",
    "##### 如果需要让程序的执行暂停指定的秒数，可以使用标准库time模块提供的sleep函数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "7a1dcea8",
   "metadata": {},
   "outputs": [],
   "source": [
    "word = \"bottles\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aece76e0",
   "metadata": {},
   "source": [
    "##### 将值“bottles”（一个字符串）赋给一个名为“word”的新变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8827347e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "98 bottles of beer on the wall.\n",
      "\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "97 bottles of beer on the wall.\n",
      "\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "96 bottles of beer on the wall.\n",
      "\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "95 bottles of beer on the wall.\n",
      "\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "94 bottles of beer on the wall.\n",
      "\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "93 bottles of beer on the wall.\n",
      "\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "92 bottles of beer on the wall.\n",
      "\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "91 bottles of beer on the wall.\n",
      "\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "90 bottles of beer on the wall.\n",
      "\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "89 bottles of beer on the wall.\n",
      "\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "88 bottles of beer on the wall.\n",
      "\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "87 bottles of beer on the wall.\n",
      "\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "86 bottles of beer on the wall.\n",
      "\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "85 bottles of beer on the wall.\n",
      "\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "84 bottles of beer on the wall.\n",
      "\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "83 bottles of beer on the wall.\n",
      "\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "82 bottles of beer on the wall.\n",
      "\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "81 bottles of beer on the wall.\n",
      "\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "80 bottles of beer on the wall.\n",
      "\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "79 bottles of beer on the wall.\n",
      "\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "78 bottles of beer on the wall.\n",
      "\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "77 bottles of beer on the wall.\n",
      "\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "76 bottles of beer on the wall.\n",
      "\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "75 bottles of beer on the wall.\n",
      "\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "74 bottles of beer on the wall.\n",
      "\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "73 bottles of beer on the wall.\n",
      "\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "72 bottles of beer on the wall.\n",
      "\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "71 bottles of beer on the wall.\n",
      "\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "70 bottles of beer on the wall.\n",
      "\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "69 bottles of beer on the wall.\n",
      "\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "68 bottles of beer on the wall.\n",
      "\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "67 bottles of beer on the wall.\n",
      "\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "66 bottles of beer on the wall.\n",
      "\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "65 bottles of beer on the wall.\n",
      "\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "64 bottles of beer on the wall.\n",
      "\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "63 bottles of beer on the wall.\n",
      "\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "62 bottles of beer on the wall.\n",
      "\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "61 bottles of beer on the wall.\n",
      "\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "60 bottles of beer on the wall.\n",
      "\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "59 bottles of beer on the wall.\n",
      "\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "58 bottles of beer on the wall.\n",
      "\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "57 bottles of beer on the wall.\n",
      "\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "56 bottles of beer on the wall.\n",
      "\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "55 bottles of beer on the wall.\n",
      "\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "54 bottles of beer on the wall.\n",
      "\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "53 bottles of beer on the wall.\n",
      "\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "52 bottles of beer on the wall.\n",
      "\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "51 bottles of beer on the wall.\n",
      "\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "50 bottles of beer on the wall.\n",
      "\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "49 bottles of beer on the wall.\n",
      "\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "48 bottles of beer on the wall.\n",
      "\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "47 bottles of beer on the wall.\n",
      "\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "46 bottles of beer on the wall.\n",
      "\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "45 bottles of beer on the wall.\n",
      "\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "44 bottles of beer on the wall.\n",
      "\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "43 bottles of beer on the wall.\n",
      "\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "42 bottles of beer on the wall.\n",
      "\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "41 bottles of beer on the wall.\n",
      "\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "40 bottles of beer on the wall.\n",
      "\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "39 bottles of beer on the wall.\n",
      "\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "38 bottles of beer on the wall.\n",
      "\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "37 bottles of beer on the wall.\n",
      "\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "36 bottles of beer on the wall.\n",
      "\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "35 bottles of beer on the wall.\n",
      "\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "34 bottles of beer on the wall.\n",
      "\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "33 bottles of beer on the wall.\n",
      "\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "32 bottles of beer on the wall.\n",
      "\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "31 bottles of beer on the wall.\n",
      "\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "30 bottles of beer on the wall.\n",
      "\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "29 bottles of beer on the wall.\n",
      "\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "28 bottles of beer on the wall.\n",
      "\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "27 bottles of beer on the wall.\n",
      "\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "26 bottles of beer on the wall.\n",
      "\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "25 bottles of beer on the wall.\n",
      "\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "24 bottles of beer on the wall.\n",
      "\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "23 bottles of beer on the wall.\n",
      "\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "22 bottles of beer on the wall.\n",
      "\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "21 bottles of beer on the wall.\n",
      "\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "20 bottles of beer on the wall.\n",
      "\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "19 bottles of beer on the wall.\n",
      "\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "18 bottles of beer on the wall.\n",
      "\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "17 bottles of beer on the wall.\n",
      "\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "16 bottles of beer on the wall.\n",
      "\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "15 bottles of beer on the wall.\n",
      "\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "14 bottles of beer on the wall.\n",
      "\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "13 bottles of beer on the wall.\n",
      "\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "12 bottles of beer on the wall.\n",
      "\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "11 bottles of beer on the wall.\n",
      "\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "10 bottles of beer on the wall.\n",
      "\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "9 bottles of beer on the wall.\n",
      "\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "8 bottles of beer on the wall.\n",
      "\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "7 bottles of beer on the wall.\n",
      "\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "6 bottles of beer on the wall.\n",
      "\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "5 bottles of beer on the wall.\n",
      "\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "4 bottles of beer on the wall.\n",
      "\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "3 bottles of beer on the wall.\n",
      "\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "2 bottles of beer on the wall.\n",
      "\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for beer_num in range(99, 0, -1):\n",
    "    print(beer_num, word, \"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    if beer_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word, \"of beer on the wall.\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5b80ec7",
   "metadata": {},
   "source": [
    "##### 将值“bottles”（一个字符串）赋给一个名为“word”的新变量。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "714afa22",
   "metadata": {},
   "source": [
    "##### 这里的range循环指定的次数，从99倒数到0.使用“beer_num\"作为循环迭代变量。\n",
    "##### 这里\"range\"调用有3个参数，而不是1个。“range”的调用有3个参数：开始(start)、结束(stop)和步长(step)。\n",
    "> 不只是会在range中遇到start，stop和step，下面介绍一下它们是什么意思\n",
    ">> START值允许你控制范围从哪里开始\n",
    "到目前为止，我们一直在用只有一个参数的range版本，根据文档，这需要指定一个范围结束值。如果没有提供其他值，range就默认使用0作为开始值，不过也可以把它设置为你选择的某个值。如果设置了开始值，就必须再提供一个结束值。这样一来，range就会成为一个多参数调用。\n",
    ">> STOP允许你控制范围何时结束。\n",
    "我们的代码中调用range（5）时就使用了这个参数。注意，生成的范围并不包含这个结束值，所以这个结束值是一个上限，但不包含在范围内。\n",
    ">> STEP值允许你控制如何生成范围。\n",
    "指定开始和结束值时，还可以（可选）指定一个步长值。默认地，步长值为1，这会告诉range按1个步长生成各个值，也就是说，0，1，2，3，4，依此类推。可以把step设置为任何值来调整步长。还可以将step设置为一个负值来调整所生成的范围的方向。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab899a5b",
   "metadata": {},
   "source": [
    "##### 这四个print函数调用显示当前迭代的歌词，“99 bottles of beer on the wall.99 bottles of beer.Take one down.Pass it around.”，每次迭代时类推。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3d74e3d",
   "metadata": {},
   "source": [
    "##### print输出完整结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d1c1518",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdb1bae8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec75e4dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "58b107a3",
   "metadata": {},
   "source": [
    "###  我的很多很多笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a570cc08",
   "metadata": {},
   "source": [
    "(①=② ①是变量 等号是赋值 赋的就是②那一堆)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b826ede0",
   "metadata": {},
   "source": [
    "单引号或者双引号又或者三引号括起来的就是字符串。不管括起来的是什么语言，如果引号里面又是引号，我们可以用“/”或者外面是双引号里面是单引号。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fe8737b",
   "metadata": {},
   "source": [
    "如果字符很复杂，str是字符串的意思"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ae971d7",
   "metadata": {},
   "source": [
    "Type检查字符串的复杂程度"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b48dfdd",
   "metadata": {},
   "source": [
    "不是看着是个数值就可以运算的，只有两个没引号的才可以运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57d9743e",
   "metadata": {},
   "source": [
    "写代码，注释非常重要。# 注释"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad7dd51a",
   "metadata": {},
   "source": [
    "datetime.Tab    程序里有的就import它 比如：import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8058b6c4",
   "metadata": {},
   "source": [
    "time.sleep"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb91313f",
   "metadata": {},
   "source": [
    "i是特指某：①如果range里面只有一个数字，它代表我们代码执行的数字。②有两个数字。③有三个数字。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e20de4e8",
   "metadata": {},
   "source": [
    "import调用 它后面是空格，其他后面可以是“.”，比如：import time 跟random.randint(1,36)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b97d799d",
   "metadata": {},
   "source": [
    "Print是变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1cf4841",
   "metadata": {},
   "source": [
    "range(5)将和for循环一起实现for循环子代码执行的次数（5）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b4e2a65",
   "metadata": {},
   "source": [
    "enumerate 枚举 产生steps的位置索引值（index）\n",
    "for i in names:取到了names中的值（values）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fda5329",
   "metadata": {},
   "source": [
    "for 遍历数据的重要操作\n",
    " > for i in names:\n",
    "   print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4d691c2",
   "metadata": {},
   "source": [
    "* 格式化：isoformat\n",
    "> 如:datetime.date.isoformat(datetime.date.todayd())\n",
    " ‘2021-09-30’"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "584c9004",
   "metadata": {},
   "source": [
    "四个空格"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "944e2141",
   "metadata": {},
   "source": [
    "Range的强大功能详细一点"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b18ded8",
   "metadata": {},
   "source": [
    "产生一系列数值的方法，通常跟for循环一起使用，决定for循环的次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d72e44b2",
   "metadata": {},
   "source": [
    "右边数减左边数 如：list(range(1,6)） ☞[1, 2, 3, 4, 5]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6eca2b7",
   "metadata": {},
   "source": [
    "Help只能看模块，看str的地方，也可以看数值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "923e6aa3",
   "metadata": {},
   "source": [
    "* 变量名i\n",
    "> 由print（i)这件案例中我们明白了，在循环过程中，变量名虽然没变，但值是动态变化的，也就意味着所有的for循环的变量值都在随着循环次数的改变而可能发生变化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebb9cc8a",
   "metadata": {},
   "source": [
    " 有空可以去python官网试试\n",
    "\n",
    "课程表：准备odds数据判断在不在当前时间 当前的时间 课表 最后print该上什么课"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60e6af62",
   "metadata": {},
   "source": [
    "def是print定义方式的函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b54d797",
   "metadata": {},
   "source": [
    " 三个点是支持字符串换行的，两个点不支持"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "781504dc",
   "metadata": {},
   "source": [
    "* 占位符有顺序！要依次填入\n",
    "> 如果有很多位置，一个HTML页面有很多数据来占用位置，对顺序要求太苛刻了，容易出错。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7d133e8",
   "metadata": {},
   "source": [
    "format()是一个字符串的格式化方法/函数 优化 占位符\n",
    "\n",
    "优势：①不需要考虑参数出现的顺序 ②多个重复项只需要赋值一次（明确数据输入(如：变量age）)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54240289",
   "metadata": {},
   "source": [
    " 在从左到右取值，右边的值取不到。左边第一个值为0（可看为左边正数，右边负数）☞0123\n",
    "                                                                              -4-3-2-1\n",
    "                                                                              -4-3-2-101234\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8e8edff",
   "metadata": {},
   "source": [
    "gitee中文 github英文 github比较好用，但挺多人用gitee。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "73b08d07",
   "metadata": {},
   "source": [
    "###### 任何代码组都可以包含任意个嵌套代码组，它们也必须缩进。python程序员谈到嵌入代码组时，通常会谈到缩进层次。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f89c162",
   "metadata": {},
   "source": [
    "占位符是有顺序的 \n",
    "占位符的优势：如果有几百个需要填进去的内容？容易顺序乱掉，出现打印结果的不正确🔜这是百分号s占位符容易出现的错误"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a719086f",
   "metadata": {},
   "source": [
    "list：列表是有顺序的，所以可以用index去取值\n",
    "\n",
    "两个列表相加顺序是不变的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f43bf1d2",
   "metadata": {},
   "source": [
    "切片slice：\n",
    "右边的值取不到 例如（0，3）索引为3的值取不到。\n",
    "当从0开始取值时，0可以忽略不写。如：list{：3}。可以倒着来取值，可以从左往右取值：也可以从右往左取值，index和slice都可以，两边都取得到。不管往哪边取值，右边的值都取不到。而且不能改变方向，比如错误的写法{-3，0}，这样就是取值为空，说明slice写错了。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "265acf9e",
   "metadata": {},
   "source": [
    "列表的基本特征：方括号 里面可以是数值可以去字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60656713",
   "metadata": {},
   "source": [
    "两个列表的顺序可以相加的，而且还能做乘法运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d76dc846",
   "metadata": {},
   "source": [
    "步长，List列表slice：[start:stop:step]\n",
    "```\n",
    "如果没有指定开始值，则默认为0；\n",
    "如果没有指定结束值，则取列表允许的最大值；\n",
    "如果没有指定步长值，则默认步长为1.\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2098cb95",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(names[:])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b012336c",
   "metadata": {},
   "source": [
    "###### 1.在从左往右取值时，右边的值取不到\n",
    "> print(names[1:3])\n",
    "######  如果从0开始取值，0可省略不写\n",
    "> print(names[:3])\n",
    "\n",
    "###### 2.在从右往左取值时，右边的值取不到\n",
    "> print(name[-3:-1])\n",
    "\n",
    "###### 怎么能取到 -1这个位置的值呢？右侧不写任何值\n",
    "print(names[-3:])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "51ffa8c7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
